#ifndef WIDGET_H
#define WIDGET_H


#include <QWidget>
#include <QTimer>
#include <QMouseEvent>
#include <QHBoxLayout>
#include <QLabel>
#include <QMenu>
#include <QSystemTrayIcon>
#include <QApplication>
#include <QFile>
#include <QTextStream>
#include <Windows.h>
#include <WtsApi32.h>
#include<iostream>
#include<thread>
#include "calendar.h"

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

protected:
    void mousePressEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void showContextMenu(const QPoint &pos);
    void handleMenuItem1();
    void handleMenuItem2();
    void handleMenuItem3();
    void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
    void exitApplication();
    void changeImage();
    void displayTextFromLine(int lineNumber);
    void drinkwater();
private:
    QPoint diff_;
    int idx;

    QHBoxLayout *hlayout;
    QLabel *l;

    QPoint rightClickPos; // 用于存储右键点击的位置
    QMenu *contextMenu;  // 右键菜单
    QSystemTrayIcon *trayIcon; //系统托盘图标
    QMenu *trayMenu; //托盘图标菜单
    int currentImageIndex;//显示的立绘编号

    bool isDragging;
    QPoint lastMousePos ;

    QLabel *textLabel;
    QTimer *timer,*timer2;
     QTimer *loop_timer;
    int flag;
    QTimer * remind_timer;

    Calendar *calendar;
    int health_time = 10000;
    QDialog * dialog;
    QDialog * dialog2;


    public slots:
    void receiveData(int data);
    private slots:
    void updateLabelBackground();
    void timeoutSlot();
signals:
    void mouseLeftButtonClicked();
};

#endif // WIDGET_H
